package cn.sumpu.app.coolsk.biz.impl;



import cn.sumpu.app.coolsk.biz.WeiboBiz;
import cn.sumpu.app.coolsk.exception.AppBusinessException;
import cn.sumpu.toolkit.weibo.AccessUser;
import cn.sumpu.toolkit.weibo.SinaWeibo;
import cn.sumpu.toolkit.weibo.TencentWeibo;

public class WeiboBizImpl implements WeiboBiz{

	private String sinaWeiboAppKey;
	private String sinaWeiboAppSecret;
	private String tencentWeiboAppKey;
	private String tencentWeiboAppSecret;
	private String webServer;
	
	public void setSinaWeiboAppKey(String sinaWeiboAppKey) {
		this.sinaWeiboAppKey = sinaWeiboAppKey;
	}

	public void setSinaWeiboAppSecret(String sinaWeiboAppSecret) {
		this.sinaWeiboAppSecret = sinaWeiboAppSecret;
	}


	public void setTencentWeiboAppKey(String tencentWeiboAppKey) {
		this.tencentWeiboAppKey = tencentWeiboAppKey;
	}

	public void setTencentWeiboAppSecret(String tencentWeiboAppSecret) {
		this.tencentWeiboAppSecret = tencentWeiboAppSecret;
	}

	public void setWebServer(String webServer) {
		this.webServer = webServer;
	}

	@Override
	public void sendMessageSina(String text, String accessToken,
			String accessSecret) throws AppBusinessException {
		SinaWeibo sinaWeibo=new SinaWeibo(sinaWeiboAppKey, sinaWeiboAppSecret);
		sinaWeibo.sendMessage(text, accessToken, accessSecret);

	}

	@Override
	public void sendMessageNetPicSina(String text, String picUrl,
			String accessToken, String accessSecret)
			throws AppBusinessException {
		SinaWeibo sinaWeibo=new SinaWeibo(sinaWeiboAppKey, sinaWeiboAppSecret);
		sinaWeibo.sendMessage(text, accessToken, accessSecret);

	}

	@Override
	public String requestOauthSina() throws AppBusinessException {
		String callbackUrl=webServer+"sinaCallBack.htm";
		SinaWeibo sinaWeibo=new SinaWeibo(sinaWeiboAppKey, sinaWeiboAppSecret);
		return sinaWeibo.requestOauth(callbackUrl);
	}

	@Override
	public String requestOauthSina(String callbackUrl)
			throws AppBusinessException {
		SinaWeibo sinaWeibo=new SinaWeibo(sinaWeiboAppKey, sinaWeiboAppSecret);
		return sinaWeibo.requestOauth(callbackUrl);
	}

	@Override
	public AccessUser requstAccessTokenSina(String oauthVerifier) throws AppBusinessException {
		SinaWeibo sinaWeibo=new SinaWeibo(sinaWeiboAppKey, sinaWeiboAppSecret);
		return sinaWeibo.requstAccessToken(oauthVerifier);
	}

	@Override
	public AccessUser getUserInfoSina(String userId, String accessToken,
			String accessSecret) throws AppBusinessException {
		SinaWeibo sinaWeibo=new SinaWeibo(sinaWeiboAppKey, sinaWeiboAppSecret);
		return sinaWeibo.getUserInfo(userId, accessToken, accessSecret);
	}

	@Override
	public String shareSina(String text, String url, String picUrl, String site)
			throws AppBusinessException {
		SinaWeibo sinaWeibo=new SinaWeibo(sinaWeiboAppKey, sinaWeiboAppSecret);
		return sinaWeibo.share(text, url, picUrl, site, sinaWeiboAppKey);
	}

	@Override
	public String shareUrlSina(String text, String url, String site)
			throws AppBusinessException {
		SinaWeibo sinaWeibo=new SinaWeibo(sinaWeiboAppKey, sinaWeiboAppSecret);
		return sinaWeibo.shareUrl(text, url, site, sinaWeiboAppKey);
	}

	@Override
	public String sharePicSina(String text, String picUrl, String site) throws AppBusinessException {
		SinaWeibo sinaWeibo=new SinaWeibo(sinaWeiboAppKey, sinaWeiboAppSecret);
		return sinaWeibo.sharePic(text, picUrl, site, sinaWeiboAppKey);
	}

	@Override
	public String shareTextSina(String text, String site )
			throws AppBusinessException {
		SinaWeibo sinaWeibo=new SinaWeibo(sinaWeiboAppKey, sinaWeiboAppSecret);
		return sinaWeibo.shareText(text, site, sinaWeiboAppKey);
	}

	@Override
	public void sendMessageLocalPicSina(String text, String picUrl,
			String accessToken, String accessSecret)
			throws AppBusinessException {
		SinaWeibo sinaWeibo=new SinaWeibo(sinaWeiboAppKey, sinaWeiboAppSecret);
		sinaWeibo.sendMessageLocalPic(text, picUrl, accessToken, accessSecret);
	}

	@Override
	public void addFollowSina(String weiboUserId, String accessToken,
			String accessSecret) throws AppBusinessException {
		SinaWeibo sinaWeibo=new SinaWeibo(sinaWeiboAppKey, sinaWeiboAppSecret);
		sinaWeibo.addFollow(weiboUserId, accessToken, accessSecret);
	}

	@Override
	public void delFollowSina(String weiboUserId, String accessToken,
			String accessSecret) throws AppBusinessException {
		SinaWeibo sinaWeibo=new SinaWeibo(sinaWeiboAppKey, sinaWeiboAppSecret);
		sinaWeibo.delFollow(weiboUserId, accessToken, accessSecret);
	}

	@Override
	public String requestOauthTencent() throws AppBusinessException {
		String callbackUrl=webServer+"tencentCallBack.htm";
		TencentWeibo tencentWeibo=new TencentWeibo(tencentWeiboAppKey, tencentWeiboAppSecret);
		return tencentWeibo.requestOauth(callbackUrl);
	}

	@Override
	public String requestOauthTencent(String callbackUrl)
			throws AppBusinessException {
		TencentWeibo tencentWeibo=new TencentWeibo(tencentWeiboAppKey, tencentWeiboAppSecret);
		return tencentWeibo.requestOauth(callbackUrl);
	}

	@Override
	public AccessUser requstAccessTokenTencent(String oauthVerifier) throws AppBusinessException {
		TencentWeibo tencentWeibo=new TencentWeibo(tencentWeiboAppKey, tencentWeiboAppSecret);
		return tencentWeibo.requstAccessToken(oauthVerifier);
	}

	@Override
	public AccessUser getUserInfoTencent(String userId, String accessToken,
			String accessSecret) throws AppBusinessException {
		TencentWeibo tencentWeibo=new TencentWeibo(tencentWeiboAppKey, tencentWeiboAppSecret);
		return tencentWeibo.getUserInfo(accessToken, accessSecret);
	}

	@Override
	public String shareTencent(String text, String url, String picUrl,
			String site) throws AppBusinessException {
		TencentWeibo tencentWeibo=new TencentWeibo(tencentWeiboAppKey, tencentWeiboAppSecret);
		return tencentWeibo.share(text, url, picUrl, site, tencentWeiboAppKey);
	}

	@Override
	public String shareUrlTencent(String text, String url, String site)
			throws AppBusinessException {
		TencentWeibo tencentWeibo=new TencentWeibo(tencentWeiboAppKey, tencentWeiboAppSecret);
		return tencentWeibo.shareUrl(text, url, site, tencentWeiboAppKey);
	}

	@Override
	public String sharePicTencent(String text, String picUrl, String site) throws AppBusinessException {
		TencentWeibo tencentWeibo=new TencentWeibo(tencentWeiboAppKey, tencentWeiboAppSecret);
		return tencentWeibo.sharePic(text, picUrl, site, tencentWeiboAppKey);
	}

	@Override
	public String shareTextTencent(String text, String site)
			throws AppBusinessException {
		TencentWeibo tencentWeibo=new TencentWeibo(tencentWeiboAppKey, tencentWeiboAppSecret);
		return tencentWeibo.shareText(text, site, tencentWeiboAppKey);
	}

	@Override
	public void sendMessageTencent(String text, String accessToken,
			String accessSecret,String clientIP) throws AppBusinessException {
		TencentWeibo tencentWeibo=new TencentWeibo(tencentWeiboAppKey, tencentWeiboAppSecret);
		tencentWeibo.sendMessage(text, accessToken, accessSecret, clientIP);
	}


	@Override
	public void sendMessageLocalPicTencent(String text, String picUrl,
			String accessToken, String accessSecret,String clientIP)
			throws AppBusinessException {
		TencentWeibo tencentWeibo=new TencentWeibo(tencentWeiboAppKey, tencentWeiboAppSecret);
		tencentWeibo.sendMessageLocalPic(text, picUrl, accessToken, accessSecret, clientIP);
	}

	@Override
	public void addFollowTencent(String weiboUserId, String accessToken,
			String accessSecret,String clientIP) throws AppBusinessException {
		TencentWeibo tencentWeibo=new TencentWeibo(tencentWeiboAppKey, tencentWeiboAppSecret);
		tencentWeibo.addFollow(weiboUserId, accessToken, accessSecret, clientIP);
	}

	@Override
	public void delFollowTencent(String weiboUserId, String accessToken,
			String accessSecret) throws AppBusinessException {
		TencentWeibo tencentWeibo=new TencentWeibo(tencentWeiboAppKey, tencentWeiboAppSecret);
		tencentWeibo.delFollow(weiboUserId, accessToken, accessSecret);
	}

}
